// vue.config.js
const path = require('path')
const WebpackIconfontPluginNodejs = require('webpack-iconfont-plugin-nodejs')
const dir = 'src/icons/'
module.exports = {
    //productionSourceMap: false,
    chainWebpack: config => {
        if (process.env.NODE_ENV === 'production') {
            config.output.filename('js/[name].js').end();
            config.output.chunkFilename('js/[name].js').end();
            // 修改生产配置
            config.plugin('extract-css').tap(args => [{
                filename: `css/[name].css`,
                chunkFilename: `css/[name].css`
            }])
        }
        // 配置svg转web字体插件
        config.plugin('webpack-iconfont-plugin-nodejs').use(WebpackIconfontPluginNodejs, [{
            fontName: 'micromap-icons',
            cssPrefix: 'mm-icon',
            svgs: path.join(dir, 'svgs/*.svg'),
            // template: path.join(dir, 'css.njk'),
            fontsOutput: path.join(dir, 'fonts/'),
            cssOutput: path.join(dir, 'fonts/font.css'),
            //htmlOutput: path.join(dir, 'fonts/_font-preview.html'),
            jsOutput: path.join(dir, 'fonts/fonts.js')
        }])
    }
}
